//Date: 2025-02-10 08:55:07
#include<bits/stdc++.h>
using namespace std;
#define P emplace_back
#define CLEAR(a,v) memset(a,(v),sizeof(a))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
char buf[1<<20],*p1,*p2;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
multiset<int> sl[1000005],sr[1000005],sL,sR;
struct Node{int maxl,minr,ans;} t[1000005*4];
inline Node pushup(Node pl,Node pr) {return {max(pl.maxl,pr.maxl),min(pl.minr,pr.minr),min({pl.ans,pr.ans,pr.minr-pl.maxl})};}
#define ls (p<<1)
#define rs (p<<1|1)
#define mid ((l+r)>>1)
void update(int p,int l,int r,int x,int v1,int v2) {
    if(l==r) {if(v1!=-1) t[p].maxl=v1;if(v2!=-1) t[p].minr=v2;return;}
    x<=mid?update(ls,l,mid,x,v1,v2):update(rs,mid+1,r,x,v1,v2);t[p]=pushup(t[ls],t[rs]);
}
void MAIN() {
    rep(i,0,4e6) t[i].maxl=-1e9,t[i].minr=1e9,t[i].ans=1e9;rep(i,1,1e6) sl[i].insert(1e9),sr[i].insert(-1e9);
    for(int q=rd();q;q--) {
        char op=getchar();while(op!='A'&&op!='R') op=getchar();int l=rd(),r=rd()-1;
        if(op=='A') {
            sL.insert(l),sR.insert(r),sl[l].insert(r),sr[r].insert(l);
            update(1,1,1e6,l,-1,*sl[l].begin());update(1,1,1e6,r,*sr[r].rbegin(),-1);
        }
        else {
            sL.erase(sL.find(l)),sR.erase(sR.find(r)),sl[l].erase(sl[l].find(r)),sr[r].erase(sr[r].find(l));
            update(1,1,1e6,l,-1,*sl[l].begin());update(1,1,1e6,r,*sr[r].rbegin(),-1);
        }
        if(*sL.rbegin()<=*sR.begin()) printf("%d\n",*sl[*sL.rbegin()].begin()-*sr[*sR.begin()].rbegin()+1);
        else printf("%d\n",t[1].ans+1);
    }
}
}
bool MED;
signed main() {
    freopen("stone.in","r",stdin);freopen("stone.out","w",stdout);
    for(int tt=1;tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}